package Ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import Controller.GameController;
import Messaging.Notification;
import Messaging.NotificationManager;

/*
 * @author Roch San Buenaventura
 */

public class GameOptions extends JPanel 
{

	private JRadioButton one_, two_, three_, four_, five_, six_, seven_, eight_;
	private JTextField nameOne_, nameTwo_, nameThree_, nameFour_, nameFive_, nameSix_, nameSeven_, nameEight_;
	private JLabel playersHeader_, playerNames_, playerOne_, playerTwo_, playerThree_, playerFour_, playerFive_, playerSix_, playerSeven_, playerEight_;
	private JButton continue_, back_, playGame_;
	private DisplayAssembler display;
	private int numberOfPlayers_ = 1, optionsPageNum_ = 1;
	private String namesAndIcons_[];
	private static Font FP = new Font("SansSerif", Font.BOLD, 12);	
	private JRadioButton player_[][];
	private JLabel selectPieces_, playerOne_2_, playerTwo_2_, playerThree_2_, playerFour_2_, playerFive_2_, playerSix_2_, playerSeven_2_, playerEight_2_;
	private JLabel player1Piece_, player2Piece_, player3Piece_, player4Piece_, player5Piece_, player6Piece_, player7Piece_, player8Piece_;
	private ImageIcon barrowIcon_, bootIcon_, carIcon_, dogIcon_, hatIcon_, ironIcon_, shipIcon_, thimbleIcon_, qmIcon_;
	private JLabel repeatError_, longNameError_, noNameError_, pieceError_;
	private ButtonGroup icons_[];
	private int numOfPieces_, maxPlayers_;
	static Image right, left, logo;
	private MainMenu mainMenu_;
	static final long serialVersionUID = 3;
    Font font;
	JLabel TitleBar, LeftImage, RightImage, LogoBar;
	
	public GameOptions(final MainMenu mainMenu)
	{

		mainMenu_ = mainMenu;

		int frameWidth = 800, frameHeight = 600;
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		Point location = new Point((int) (screen.getWidth() - frameWidth) / 2,
				(int) (screen.getHeight() - frameHeight) / 2);
		this.setSize(frameWidth, frameHeight);
		this.setLayout(null);
		
		String barrow = "Barrow";
		String boot = "Boot";
		String car = "Car";
		String dog = "Dog";
		String hat = "Hat";
		String iron = "Iron";
		String ship = "Ship";
		String thimble = "Thimble"; 

		this.setBackground(Color.black);
		
		TitleBar = new JLabel();
		ImageIcon title = new ImageIcon("MonopolyImages/Logos/mlogo.jpg");
		TitleBar.setIcon(title);
		TitleBar.setBounds(150, 40, 500, 125); 
				
		LeftImage = new JLabel();
		ImageIcon Li = new ImageIcon("MonopolyImages/Logos/leftMply.jpg");
		LeftImage.setIcon(Li);
		LeftImage.setBounds(10, 180, 200, 250); 
		
		RightImage = new JLabel();
		ImageIcon Ri = new ImageIcon("MonopolyImages/Logos/rightMply.jpg");
		RightImage.setIcon(Ri);
		RightImage.setBounds(590, 180, 200, 250); 
				
		playersHeader_ = new JLabel("Number of Players:");
		playersHeader_.setForeground(Color.WHITE);
		playersHeader_.setFont(FP);
		playersHeader_.setBounds(230, 180, 130, 20); 

		playerNames_ = new JLabel("Player Names:");
		playerNames_.setForeground(Color.WHITE);
		playerNames_.setFont(FP);
		playerNames_.setBounds(403, 180, 130, 20);

		playerOne_ = new JLabel("Player 1: ");
		playerOne_.setForeground(Color.WHITE);
		playerOne_.setFont(FP);
		playerOne_.setBounds(345, 210, 100, 20); 

		playerTwo_ = new JLabel("Player 2: ");
		playerTwo_.setForeground(Color.WHITE);
		playerTwo_.setFont(FP);
		playerTwo_.setBounds(345, 230, 100, 20); 
		
		playerThree_ = new JLabel("Player 3: ");
		playerThree_.setForeground(Color.WHITE);
		playerThree_.setFont(FP);
		playerThree_.setBounds(345, 250, 100, 20);
		
		playerFour_ = new JLabel("Player 4: ");
		playerFour_.setForeground(Color.WHITE);
		playerFour_.setFont(FP);
		playerFour_.setBounds(345, 270, 150, 20); 
		
		playerFive_ = new JLabel("Player 5: ");
		playerFive_.setForeground(Color.WHITE);
		playerFive_.setFont(FP);
		playerFive_.setVisible(false);
		playerFive_.setBounds(345, 290, 150, 20);
		
		playerSix_ = new JLabel("Player 6: ");
		playerSix_.setForeground(Color.WHITE);
		playerSix_.setFont(FP);
		playerSix_.setVisible(false);
		playerSix_.setBounds(345, 310, 150, 20);
		
		playerSeven_ = new JLabel("Player 7: ");
		playerSeven_.setForeground(Color.WHITE);
		playerSeven_.setFont(FP);
		playerSeven_.setVisible(false);
		playerSeven_.setBounds(345, 330, 150, 20);
		
		playerEight_ = new JLabel("Player 8: ");
		playerEight_.setForeground(Color.WHITE);
		playerEight_.setFont(FP);
		playerEight_.setVisible(false);
		playerEight_.setBounds(345, 350, 150, 20);
		
		selectPieces_ = new JLabel();
		ImageIcon CT = new ImageIcon("MonopolyImages/New Tokens/ChooseToken.png");
		selectPieces_.setIcon(CT);
		selectPieces_.setBounds(20, 50, 150, 20); 
		
		playerOne_2_ = new JLabel();
		playerOne_2_.setBounds(20, 75, 190, 200);

		playerTwo_2_ = new JLabel();
		playerTwo_2_.setBounds(210, 75, 190, 200);

		playerThree_2_ = new JLabel();
		playerThree_2_.setBounds(400, 75, 190, 200);

		playerFour_2_ = new JLabel();
		playerFour_2_.setBounds(590, 75, 190, 200);

		playerFive_2_ = new JLabel();
		playerFive_2_.setBounds(20, 325, 190, 200);
		
		playerSix_2_ = new JLabel();
		playerSix_2_.setBounds(210, 325, 190, 200);

		playerSeven_2_ = new JLabel();
		playerSeven_2_.setBounds(400, 325, 190, 200);

		playerEight_2_ = new JLabel();
		playerEight_2_.setBounds(590, 325, 190, 200);

		one_ = new JRadioButton("1");
		one_.setBounds(265, 210, 35, 20);
		one_.setSelected(false);
		one_.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent event)
			{
				GameOptions.this.showOne();
				numberOfPlayers_ = 1;
			}
		});
		
		two_ = new JRadioButton("2");
		two_.setBounds(265, 230, 35, 20);
		two_.setSelected(false);
		two_.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				GameOptions.this.showTwo();
				numberOfPlayers_ = 2;
			}
		}); 

		three_ = new JRadioButton("3");
		three_.setBounds(265, 250, 35, 20);
		three_.setSelected(false);
		three_.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent event) 
			{
				GameOptions.this.showThree();
				numberOfPlayers_ = 3;
			}
		}); 

		four_ = new JRadioButton("4");
		four_.setBounds(265, 270, 35, 20);
		four_.setSelected(false);
		four_.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent event) 
			{
				GameOptions.this.showFour();
				numberOfPlayers_ = 4;
			}
		}); 

		five_ = new JRadioButton("5");
		five_.setBounds(265, 290, 35, 20);
		five_.setSelected(false);
		five_.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				GameOptions.this.showFive();
				numberOfPlayers_ = 5;
			}
		}); 
		
		six_ = new JRadioButton("6");
		six_.setBounds(265, 310, 35, 20);
		six_.setSelected(false);
		six_.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				GameOptions.this.showSix();
				numberOfPlayers_ = 6;
			}
		});
		
		seven_ = new JRadioButton("7");
		seven_.setBounds(265, 330, 35, 20);
		seven_.setSelected(false);
		seven_.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				GameOptions.this.showSeven();
				numberOfPlayers_ = 7;
			} 
		});
		
		eight_ = new JRadioButton("8");
		eight_.setBounds(265, 350, 35, 20);
		eight_.setSelected(false);
		eight_.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event) 
			{
				GameOptions.this.showEight();
				numberOfPlayers_ = 8;
			}
		});
		
		ButtonGroup players_ = new ButtonGroup(); 
		players_.add(one_);
		players_.add(two_);
		players_.add(three_);
		players_.add(four_);
		players_.add(five_);
		players_.add(six_);
		players_.add(seven_);
		players_.add(eight_);
		
		//done
		qmIcon_ = new ImageIcon("MonopolyImages/New Tokens/qm.jpg");
		barrowIcon_ = new ImageIcon("MonopolyImages/New Tokens/Barrow.png");
		bootIcon_ = new ImageIcon("MonopolyImages/New Tokens/Boot.png");
		carIcon_ = new ImageIcon("MonopolyImages/New Tokens/Car.png");
		dogIcon_ = new ImageIcon("MonopolyImages/New Tokens/Dog.png");
		hatIcon_ =  new ImageIcon("MonopolyImages/New Tokens/Hat.png");
		ironIcon_ =  new ImageIcon("MonopolyImages/New Tokens/Iron.png"); 
		shipIcon_ =  new ImageIcon("MonopolyImages/New Tokens/Ship.png"); 
		thimbleIcon_ =  new ImageIcon("MonopolyImages/New Tokens/Thimble.png");
		
		player1Piece_ = new JLabel();
		player1Piece_.setBounds(90, 200, 50, 50);
		this.add(player1Piece_);
		
		player2Piece_ = new JLabel();
		player2Piece_.setBounds(280, 200, 50, 50);
		this.add(player2Piece_);

		player3Piece_ = new JLabel();
		player3Piece_.setBounds(470, 200, 50, 50);
		this.add(player3Piece_);

		player4Piece_ = new JLabel();
		player4Piece_.setBounds(660, 200, 50, 50);
		this.add(player4Piece_);

		player5Piece_ = new JLabel();
		player5Piece_.setBounds(90, 450, 50, 50);
		this.add(player5Piece_);

		player6Piece_ = new JLabel();
		player6Piece_.setBounds(280, 450, 50, 50);
		this.add(player6Piece_);

		player7Piece_ = new JLabel();
		player7Piece_.setBounds(470, 450, 50, 50);
		this.add(player7Piece_);

		player8Piece_ = new JLabel();
		player8Piece_.setBounds(660, 450, 50, 50);
		this.add(player8Piece_);

		maxPlayers_ = 8;
		numOfPieces_ = 8;

		player_ = new JRadioButton[maxPlayers_][numOfPieces_];
		icons_ = new ButtonGroup[numOfPieces_];

		player_[0][0] = new JRadioButton(barrow);
		player_[0][0].setBounds(40, 100, 70, 20);
		player_[0][0].addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent event) 
			{
				player1Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[0][1] = new JRadioButton(boot);
		player_[0][1].setBounds(40, 120, 70, 20);
		player_[0][1].addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				player1Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[0][2] = new JRadioButton(car);
		player_[0][2].setBounds(40, 140, 70, 20);
		player_[0][2].addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				player1Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[0][3] = new JRadioButton(dog);
		player_[0][3].setBounds(40, 160, 70, 20);
		player_[0][3].addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent event) 
			{
				player1Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[0][4] = new JRadioButton(hat);
		player_[0][4].setBounds(110, 100, 70, 20);
		player_[0][4].addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				player1Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[0][5] = new JRadioButton(iron);
		player_[0][5].setBounds(110, 120, 70, 20);
		player_[0][5].addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				player1Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[0][6] = new JRadioButton(ship);
		player_[0][6].setBounds(110, 140, 70, 20);
		player_[0][6].addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				player1Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});
		player_[0][7] = new JRadioButton(thimble);
		player_[0][7].setBounds(110, 160, 70, 20);
		player_[0][7].addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				player1Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});
		
		icons_[0] = new ButtonGroup();
		icons_[0].add(player_[0][0]);
		icons_[0].add(player_[0][1]);
		icons_[0].add(player_[0][2]);
		icons_[0].add(player_[0][3]);
		icons_[0].add(player_[0][4]);
		icons_[0].add(player_[0][5]);
		icons_[0].add(player_[0][6]);
		icons_[0].add(player_[0][7]);
		
		player_[1][0] = new JRadioButton(barrow);
		player_[1][0].setBounds(230, 100, 70, 20);
		player_[1][0].addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event)
			{
				player2Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[1][1] = new JRadioButton(boot);
		player_[1][1].setBounds(230, 120, 70, 20);
		player_[1][1].addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent event)
			{
				player2Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[1][2] = new JRadioButton(car);
		player_[1][2].setBounds(230, 140, 70, 20);
		player_[1][2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player2Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[1][3] = new JRadioButton(dog);
		player_[1][3].setBounds(230, 160, 70, 20);
		player_[1][3].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player2Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[1][4] = new JRadioButton(hat);
		player_[1][4].setBounds(300, 100, 70, 20);
		player_[1][4].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player2Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[1][5] = new JRadioButton(iron);
		player_[1][5].setBounds(300, 120, 70, 20);
		player_[1][5].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player2Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[1][6] = new JRadioButton(ship);
		player_[1][6].setBounds(300, 140, 70, 20);
		player_[1][6].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player2Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[1][7] = new JRadioButton(thimble);
		player_[1][7].setBounds(300, 160, 70, 20);
		player_[1][7].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player2Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		icons_[1] = new ButtonGroup();
		icons_[1].add(player_[1][0]);
		icons_[1].add(player_[1][1]);
		icons_[1].add(player_[1][2]);
		icons_[1].add(player_[1][3]);
		icons_[1].add(player_[1][4]);
		icons_[1].add(player_[1][5]);
		icons_[1].add(player_[1][6]);
		icons_[1].add(player_[1][7]);
		
		player_[2][0] = new JRadioButton(barrow);
		player_[2][0].setBounds(420, 100, 70, 20);
		player_[2][0].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[2][1] = new JRadioButton(boot);
		player_[2][1].setBounds(420, 120, 70, 20);
		player_[2][1].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[2][2] = new JRadioButton(car);
		player_[2][2].setBounds(420, 140, 70, 20);
		player_[2][2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[2][3] = new JRadioButton(dog);
		player_[2][3].setBounds(420, 160, 70, 20);
		player_[2][3].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[2][4] = new JRadioButton(hat);
		player_[2][4].setBounds(490, 100, 70, 20);
		player_[2][4].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[2][5] = new JRadioButton(iron);
		player_[2][5].setBounds(490, 120, 70, 20);
		player_[2][5].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[2][6] = new JRadioButton(ship);
		player_[2][6].setBounds(490, 140, 70, 20);
		player_[2][6].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[2][7] = new JRadioButton(thimble);
		player_[2][7].setBounds(490, 160, 70, 20);
		player_[2][7].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player3Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		icons_[2] = new ButtonGroup();
		icons_[2].add(player_[2][0]);
		icons_[2].add(player_[2][1]);
		icons_[2].add(player_[2][2]);
		icons_[2].add(player_[2][3]);
		icons_[2].add(player_[2][4]);
		icons_[2].add(player_[2][5]);
		icons_[2].add(player_[2][6]);
		icons_[2].add(player_[2][7]);
		
		player_[3][0] = new JRadioButton(barrow);
		player_[3][0].setBounds(610, 100, 70, 20);
		player_[3][0].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[3][1] = new JRadioButton(boot);
		player_[3][1].setBounds(610, 120, 70, 20);
		player_[3][1].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[3][2] = new JRadioButton(car);
		player_[3][2].setBounds(610, 140, 70, 20);
		player_[3][2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[3][3] = new JRadioButton(dog);
		player_[3][3].setBounds(610, 160, 70, 20);
		player_[3][3].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[3][4] = new JRadioButton(hat);
		player_[3][4].setBounds(680, 100, 70, 20);
		player_[3][4].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[3][5] = new JRadioButton(iron);
		player_[3][5].setBounds(680, 120, 70, 20);
		player_[3][5].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[3][6] = new JRadioButton(ship);
		player_[3][6].setBounds(680, 140, 70, 20);
		player_[3][6].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[3][7] = new JRadioButton(thimble);
		player_[3][7].setBounds(680, 160, 70, 20);
		player_[3][7].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player4Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		icons_[3] = new ButtonGroup();
		icons_[3].add(player_[3][0]);
		icons_[3].add(player_[3][1]);
		icons_[3].add(player_[3][2]);
		icons_[3].add(player_[3][3]);
		icons_[3].add(player_[3][4]);
		icons_[3].add(player_[3][5]);
		icons_[3].add(player_[3][6]);
		icons_[3].add(player_[3][7]);
		
		player_[4][0] = new JRadioButton(barrow);
		player_[4][0].setBounds(40, 350, 70, 20);
		player_[4][0].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[4][1] = new JRadioButton(boot);
		player_[4][1].setBounds(40, 370, 70, 20);
		player_[4][1].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[4][2] = new JRadioButton(car);
		player_[4][2].setBounds(40, 390, 70, 20);
		player_[4][2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[4][3] = new JRadioButton(dog);
		player_[4][3].setBounds(40, 410, 70, 20);
		player_[4][3].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[4][4] = new JRadioButton(hat);
		player_[4][4].setBounds(110, 350, 70, 20);
		player_[4][4].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});
		
		player_[4][5] = new JRadioButton(iron);
		player_[4][5].setBounds(110, 370, 70, 20);
		player_[4][5].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[4][6] = new JRadioButton(ship);
		player_[4][6].setBounds(110, 390, 70, 20);
		player_[4][6].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[4][7] = new JRadioButton(thimble);
		player_[4][7].setBounds(110, 410, 70, 20);
		player_[4][7].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player5Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		icons_[4] = new ButtonGroup();
		icons_[4].add(player_[4][0]);
		icons_[4].add(player_[4][1]);
		icons_[4].add(player_[4][2]);
		icons_[4].add(player_[4][3]);
		icons_[4].add(player_[4][4]);
		icons_[4].add(player_[4][5]);
		icons_[4].add(player_[4][6]);
		icons_[4].add(player_[4][7]);

		player_[5][0] = new JRadioButton(barrow);
		player_[5][0].setBounds(230, 350, 70, 20);
		player_[5][0].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[5][1] = new JRadioButton(boot);
		player_[5][1].setBounds(230, 370, 70, 20);
		player_[5][1].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[5][2] = new JRadioButton(car);
		player_[5][2].setBounds(230, 390, 70, 20);
		player_[5][2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[5][3] = new JRadioButton(dog);
		player_[5][3].setBounds(230, 410, 70, 20);
		player_[5][3].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[5][4] = new JRadioButton(hat);
		player_[5][4].setBounds(300, 350, 70, 20);
		player_[5][4].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[5][5] = new JRadioButton(iron);
		player_[5][5].setBounds(300, 370, 70, 20);
		player_[5][5].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[5][6] = new JRadioButton(ship);
		player_[5][6].setBounds(300, 390, 70, 20);
		player_[5][6].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[5][7] = new JRadioButton(thimble);
		player_[5][7].setBounds(300, 410, 70, 20);
		player_[5][7].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player6Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		icons_[5] = new ButtonGroup();
		icons_[5].add(player_[5][0]);
		icons_[5].add(player_[5][1]);
		icons_[5].add(player_[5][2]);
		icons_[5].add(player_[5][3]);
		icons_[5].add(player_[5][4]);
		icons_[5].add(player_[5][5]);
		icons_[5].add(player_[5][6]);
		icons_[5].add(player_[5][7]);

		player_[6][0] = new JRadioButton(barrow);
		player_[6][0].setBounds(420, 350, 70, 20);
		player_[6][0].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[6][1] = new JRadioButton(boot);
		player_[6][1].setBounds(420, 370, 70, 20);
		player_[6][1].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[6][2] = new JRadioButton(car);
		player_[6][2].setBounds(420, 390, 70, 20);
		player_[6][2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[6][3] = new JRadioButton(dog);
		player_[6][3].setBounds(420, 410, 70, 20);
		player_[6][3].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[6][4] = new JRadioButton(hat);
		player_[6][4].setBounds(490, 350, 70, 20);
		player_[6][4].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[6][5] = new JRadioButton(iron);
		player_[6][5].setBounds(490, 370, 70, 20);
		player_[6][5].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[6][6] = new JRadioButton(ship);
		player_[6][6].setBounds(490, 390, 70, 20);
		player_[6][6].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[6][7] = new JRadioButton(thimble);
		player_[6][7].setBounds(490, 410, 70, 20);
		player_[6][7].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player7Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		icons_[6] = new ButtonGroup();
		icons_[6].add(player_[6][0]);
		icons_[6].add(player_[6][1]);
		icons_[6].add(player_[6][2]);
		icons_[6].add(player_[6][3]);
		icons_[6].add(player_[6][4]);
		icons_[6].add(player_[6][5]);
		icons_[6].add(player_[6][6]);
		icons_[6].add(player_[6][7]);

		player_[7][0] = new JRadioButton(barrow);
		player_[7][0].setBounds(610, 350, 70, 20);
		player_[7][0].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(barrowIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[7][1] = new JRadioButton(boot);
		player_[7][1].setBounds(610, 370, 70, 20);
		player_[7][1].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(bootIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[7][2] = new JRadioButton(car);
		player_[7][2].setBounds(610, 390, 70, 20);
		player_[7][2].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(carIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[7][3] = new JRadioButton(dog);
		player_[7][3].setBounds(610, 410, 70, 20);
		player_[7][3].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(dogIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[7][4] = new JRadioButton(hat);
		player_[7][4].setBounds(680, 350, 70, 20);
		player_[7][4].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(hatIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[7][5] = new JRadioButton(iron);
		player_[7][5].setBounds(680, 370, 70, 20);
		player_[7][5].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(ironIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[7][6] = new JRadioButton(ship);
		player_[7][6].setBounds(680, 390, 70, 20);
		player_[7][6].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(shipIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		player_[7][7] = new JRadioButton(thimble);
		player_[7][7].setBounds(680, 410, 70, 20);
		player_[7][7].addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				player8Piece_.setIcon(thimbleIcon_);
				GameOptions.this.refreshPieceButtons();
			}
		});

		icons_[7] = new ButtonGroup();
		icons_[7].add(player_[7][0]);
		icons_[7].add(player_[7][1]);
		icons_[7].add(player_[7][2]);
		icons_[7].add(player_[7][3]);
		icons_[7].add(player_[7][4]);
		icons_[7].add(player_[7][5]);
		icons_[7].add(player_[7][6]);
		icons_[7].add(player_[7][7]);

		for (int i = 0; i < this.maxPlayers_; i++) {
			player_[i][0].setActionCommand(barrow);
			player_[i][1].setActionCommand(boot);
			player_[i][2].setActionCommand(car);
			player_[i][3].setActionCommand(dog);
			player_[i][4].setActionCommand(hat);
			player_[i][5].setActionCommand(iron);
			player_[i][6].setActionCommand(ship);
			player_[i][7].setActionCommand(thimble);
		}

		nameOne_ = new JTextField();
		nameOne_.setBounds(405, 210, 100, 20);
		nameOne_.setVisible(false); //done

		nameTwo_ = new JTextField();
		nameTwo_.setBounds(405, 230, 100, 20);
		nameTwo_.setVisible(false); //done

		nameThree_ = new JTextField();
		nameThree_.setBounds(405, 250, 100, 20);
		nameThree_.setVisible(false); //done
		
		nameFour_ = new JTextField();
		nameFour_.setBounds(405, 270, 100, 20);
		nameFour_.setVisible(false); //done
		
		nameFive_ = new JTextField();
		nameFive_.setBounds(405, 290, 100, 20);
		nameFive_.setVisible(false); //done
		
		nameSix_ = new JTextField();
		nameSix_.setBounds(405, 310, 100, 20);
		nameSix_.setVisible(false); //done
		
		nameSeven_ = new JTextField();
		nameSeven_.setBounds(405, 330, 100, 20);
		nameSeven_.setVisible(false); //done
		
		nameEight_ = new JTextField();
		nameEight_.setBounds(405, 350, 100, 20);
		nameEight_.setVisible(false); //done
		
		continue_ = new JButton("Next");
		continue_.setMnemonic(KeyEvent.VK_N);
		continue_.setBounds(680, 550, 90, 20);
		continue_.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				noNameError_.setVisible(false);
				longNameError_.setVisible(false);
				repeatError_.setVisible(false);

				namesAndIcons_ = new String[(2 * numberOfPlayers_) + 1];

				namesAndIcons_[0] = "" + numberOfPlayers_;

				namesAndIcons_[1] = nameOne_.getText();
				playerOne_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[1] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
				
				if (numberOfPlayers_ > 1)
				{
					namesAndIcons_[2] = nameTwo_.getText();
					playerTwo_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[2] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
				
					if (numberOfPlayers_ > 2) 
					{
						namesAndIcons_[3] = nameThree_.getText();
						playerThree_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[3] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
					
						if (numberOfPlayers_ > 3) 
						{
							namesAndIcons_[4] = nameFour_.getText();
							playerFour_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[4] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
							
							if (numberOfPlayers_ > 4) 
							{
								namesAndIcons_[5] = nameFive_.getText();
								playerFive_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[5] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
								
								if (numberOfPlayers_ > 5) 
								{
									namesAndIcons_[6] = nameSix_.getText();
									playerSix_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[6] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
								
									if (numberOfPlayers_ > 6) 
									{
										namesAndIcons_[7] = nameSeven_.getText();
										playerSeven_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[7] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
									
										if (numberOfPlayers_ == 8) 
										{
											namesAndIcons_[8] = nameEight_.getText();
											playerEight_2_.setBorder(new TitledBorder(null, "  " + namesAndIcons_[8] + "  ", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION, null, Color.white));
										}
									}
								}
							}
						}
					}
				}
				
				if (noRepeatNames() && shortNames() && allHaveNames()) {
					GameOptions.this.hideFirstPagePanels();
					GameOptions.this.showSecondPagePanels();
					optionsPageNum_ = 2;
				}
			}

			public boolean noRepeatNames() 
			{
				for (int i = 1; i <= numberOfPlayers_; i++) 
				{
					for (int j = i + 1; j <= numberOfPlayers_; j++) 
					{
						if (namesAndIcons_[i].equals(namesAndIcons_[j])) 
						{
							repeatError_.setVisible(true);
							return false;
						}
					}
				}
				return true;
			}

			public boolean shortNames() 
			{
				for (int i = 1; i <= numberOfPlayers_; i++) 
				{
					if (namesAndIcons_[i].length() > 20) 
					{
						longNameError_.setVisible(true);
						return false;
					}
				}
				return true;
			}

			public boolean allHaveNames() 
			{
				for (int i = 1; i <= numberOfPlayers_; i++) 
				{
					if (namesAndIcons_[i].length() == 0) 
					{
						noNameError_.setVisible(true);
						return false;
					}
				}
				return true;
			}
		});

		back_ = new JButton("Back");
		back_.setMnemonic(KeyEvent.VK_B);
		back_.setBounds(580, 550, 90, 20);
		back_.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				if (optionsPageNum_ == 1)
					GameOptions.this.backToMain();
				else
					GameOptions.this.backToFirstPage();

			}
		});

		playGame_ = new JButton("Play");
		playGame_.setMnemonic(KeyEvent.VK_P);
		playGame_.setBounds(680, 550, 90, 20);
		playGame_.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {

				if ((icons_[0].getSelection() == null)
						|| (numberOfPlayers_ > 1 && icons_[1].getSelection() == null)
						|| (numberOfPlayers_ > 2 && icons_[2].getSelection() == null)
						|| (numberOfPlayers_ > 3 && icons_[3].getSelection() == null)
						|| (numberOfPlayers_ > 4 && icons_[4].getSelection() == null)
						|| (numberOfPlayers_ > 5 && icons_[5].getSelection() == null)
						|| (numberOfPlayers_ > 6 && icons_[6].getSelection() == null)
						|| (numberOfPlayers_ > 7 && icons_[7].getSelection() == null)){
					pieceError_.setVisible(true);
				}

				else {
					new GameController(mainMenu.display_);
					pieceError_.setVisible(false);
					
					for (int i = 0; i < numberOfPlayers_; i++) 
					{
						namesAndIcons_[numberOfPlayers_ + i + 1] = icons_[i]
								.getSelection().getActionCommand();
					}

					NotificationManager.getInstance().notifyObservers(
							Notification.START_GAME, namesAndIcons_);
					GameOptions.this.hideSecondPagePanels();
					GameOptions.this.setVisible(false);
					
				}
			}

		});

		font = new Font("SansSerif", Font.BOLD, 20);
		
		repeatError_ = new JLabel("ENTER A UNIQUE NAME!!!");
		repeatError_.setForeground(Color.white);
		repeatError_.setBounds(275, 500, 600, 40);
		repeatError_.setFont(font);
		repeatError_.setVisible(false);

		longNameError_ = new JLabel(
				"NAME MUST BE NOT MORE THAN 20 CHARACTERS!!!");
		longNameError_.setForeground(Color.white);
		longNameError_.setBounds(150, 500, 700, 40);
		longNameError_.setFont(font);
		longNameError_.setVisible(false);

		noNameError_ = new JLabel("ALL PLAYERS MUST HAVE A NAME!!!");
		noNameError_.setForeground(Color.white);
		noNameError_.setBounds(225, 500, 700, 40);
		noNameError_.setFont(font);
		noNameError_.setVisible(false);

		pieceError_ = new JLabel("PLAYERS MUST CHOOSE A TOKEN!!!");	
		pieceError_.setForeground(Color.white);
		pieceError_.setBounds(200, 535, 700, 40);
		pieceError_.setFont(font);
		pieceError_.setVisible(false);

		this.add(TitleBar);
		this.add(LeftImage, BorderLayout.WEST);
		this.add(RightImage, BorderLayout.EAST);
		this.add(playersHeader_);
		this.add(playerNames_);
		this.add(playerOne_);
		this.add(playerTwo_);
		this.add(playerThree_);
		this.add(playerFour_);
		this.add(playerFive_);
		this.add(playerSix_);
		this.add(playerSeven_);
		this.add(playerEight_);
		this.add(one_);
		this.add(two_);
		this.add(three_);
		this.add(four_);
		this.add(five_);
		this.add(six_);
		this.add(seven_);
		this.add(eight_);
		this.add(nameOne_);
		this.add(nameTwo_);
		this.add(nameThree_);
		this.add(nameFour_);
		this.add(nameFive_);
		this.add(nameSix_);
		this.add(nameSeven_);
		this.add(nameEight_);
		this.add(continue_);
		this.add(back_);
		this.add(playGame_);

		for (int i = 0; i < maxPlayers_; i++) 
		{
			for (int j = 0; j < numOfPieces_; j++)
				this.add(player_[i][j]);
		}

		this.add(selectPieces_);
		this.add(playerOne_2_);
		this.add(playerTwo_2_);
		this.add(playerThree_2_);
		this.add(playerFour_2_);
		this.add(playerFive_2_);
		this.add(playerSix_2_);
		this.add(playerSeven_2_);
		this.add(playerEight_2_);

		this.add(repeatError_);
		this.add(longNameError_);
		this.add(noNameError_);
		this.add(pieceError_);

		display = DisplayAssembler.getInstance();
		display.addComponent(this, location, JLayeredPane.POPUP_LAYER);
		this.setVisible(true);
		this.hideSecondPagePanels();

		NotificationManager.getInstance().addObserver(Notification.START_GAME,
				this, "backToMain");
	}

	public void refreshPieceButtons() {

		for (int i = 0; i < maxPlayers_; i++) {
			for (int j = 0; j < numOfPieces_; j++)
				player_[i][j].setEnabled(true);
		}

		for (int i = 0; i < maxPlayers_; i++) {
			for (int j = 0; j < numOfPieces_; j++) {
				if (player_[i][j].isSelected()) {

					for (int z = 1; z < maxPlayers_; z++) {
						player_[(i + z) % maxPlayers_][j].setEnabled(false);
					}

					break;
				}
			}
		}
	}

	public void hideFirstPagePanels() {
		TitleBar.setVisible(false);
		LeftImage.setVisible(false);
		RightImage.setVisible(false);
		
		playerOne_.setVisible(false);
		nameOne_.setVisible(false);
		playerTwo_.setVisible(false);
		nameTwo_.setVisible(false);
		playerThree_.setVisible(false);
		nameThree_.setVisible(false);
		playerFour_.setVisible(false);
		nameFour_.setVisible(false);
		playerFive_.setVisible(false);
		nameFive_.setVisible(false);
		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		one_.setVisible(false);
		two_.setVisible(false);
		three_.setVisible(false);
		four_.setVisible(false);
		five_.setVisible(false);
		six_.setVisible(false);
		seven_.setVisible(false);
		eight_.setVisible(false);

		continue_.setVisible(false);
		playerNames_.setVisible(false);
		playersHeader_.setVisible(false);
	} //done

	public void showFirstPagePanels() {

		TitleBar.setVisible(true);
		LeftImage.setVisible(true);
		RightImage.setVisible(true);
		
		one_.setVisible(true);
		two_.setVisible(true);
		three_.setVisible(true);
		four_.setVisible(true);
		five_.setVisible(true);
		six_.setVisible(true);
		seven_.setVisible(true);
		eight_.setVisible(true);

		continue_.setVisible(true);
		playerNames_.setVisible(true);
		playersHeader_.setVisible(true);
	} //done

	public void showSecondPagePanels() {

		selectPieces_.setVisible(true);
		playGame_.setVisible(true);

		playerOne_2_.setVisible(true);
		player1Piece_.setIcon(qmIcon_);
		player_[0][0].setVisible(true);
		player_[0][1].setVisible(true);
		player_[0][2].setVisible(true);
		player_[0][3].setVisible(true);
		player_[0][4].setVisible(true);
		player_[0][5].setVisible(true);
		player_[0][6].setVisible(true);
		player_[0][7].setVisible(true);
		player1Piece_.setVisible(true);

		if (numberOfPlayers_ > 1)
		{
		playerTwo_2_.setVisible(true);
		player2Piece_.setIcon(qmIcon_);
		player_[1][0].setVisible(true);
		player_[1][1].setVisible(true);
		player_[1][2].setVisible(true);
		player_[1][3].setVisible(true);
		player_[1][4].setVisible(true);
		player_[1][5].setVisible(true);
		player_[1][6].setVisible(true);
		player_[1][7].setVisible(true);
		player2Piece_.setVisible(true);

			if (numberOfPlayers_ > 2) 
			{
				playerThree_2_.setVisible(true);
				player3Piece_.setIcon(qmIcon_);
				player_[2][0].setVisible(true);
				player_[2][1].setVisible(true);
				player_[2][2].setVisible(true);
				player_[2][3].setVisible(true);
				player_[2][4].setVisible(true);
				player_[2][5].setVisible(true);
				player_[2][6].setVisible(true);
				player_[2][7].setVisible(true);	
				player3Piece_.setVisible(true);

				if (numberOfPlayers_ > 3)
				{
					playerFour_2_.setVisible(true);
					player4Piece_.setIcon(qmIcon_);
					player_[3][0].setVisible(true);
					player_[3][1].setVisible(true);
					player_[3][2].setVisible(true);
					player_[3][3].setVisible(true);
					player_[3][4].setVisible(true);
					player_[3][5].setVisible(true);
					player_[3][6].setVisible(true);
					player_[3][7].setVisible(true);
					player4Piece_.setVisible(true);
				
					if (numberOfPlayers_ > 4)
					{
						playerFive_2_.setVisible(true);
						player5Piece_.setIcon(qmIcon_);
						player_[4][0].setVisible(true);
						player_[4][1].setVisible(true);
						player_[4][2].setVisible(true);
						player_[4][3].setVisible(true);
						player_[4][4].setVisible(true);
						player_[4][5].setVisible(true);
						player_[4][6].setVisible(true);
						player_[4][7].setVisible(true);
						player5Piece_.setVisible(true);
					
						if (numberOfPlayers_ > 5)
						{
							playerSix_2_.setVisible(true);
							player6Piece_.setIcon(qmIcon_);
							player_[5][0].setVisible(true);
							player_[5][1].setVisible(true);
							player_[5][2].setVisible(true);
							player_[5][3].setVisible(true);
							player_[5][4].setVisible(true);
							player_[5][5].setVisible(true);
							player_[5][6].setVisible(true);
							player_[5][7].setVisible(true);
							player6Piece_.setVisible(true);
						
							if (numberOfPlayers_ > 6)
							{
								playerSeven_2_.setVisible(true);
								player7Piece_.setIcon(qmIcon_);
								player_[6][0].setVisible(true);
								player_[6][1].setVisible(true);
								player_[6][2].setVisible(true);
								player_[6][3].setVisible(true);
								player_[6][4].setVisible(true);
								player_[6][5].setVisible(true);
								player_[6][6].setVisible(true);
								player_[6][7].setVisible(true);
								player7Piece_.setVisible(true);
							
								if (numberOfPlayers_ == 8)
								{
									playerEight_2_.setVisible(true);
									player8Piece_.setIcon(qmIcon_);
									player_[7][0].setVisible(true);
									player_[7][1].setVisible(true);
									player_[7][2].setVisible(true);
									player_[7][3].setVisible(true);
									player_[7][4].setVisible(true);
									player_[7][5].setVisible(true);
									player_[7][6].setVisible(true);
									player_[7][7].setVisible(true);
									player8Piece_.setVisible(true);
								}
							}
						}
					}
				}
			}
		}
	}

	public void hideSecondPagePanels() {
		
		playerOne_.setVisible(false);
		nameOne_.setVisible(false);
		playerTwo_.setVisible(false);
		nameTwo_.setVisible(false);
		playerThree_.setVisible(false);
		nameThree_.setVisible(false);
		playerFour_.setVisible(false);
		nameFour_.setVisible(false);
		playerFive_.setVisible(false);
		nameFive_.setVisible(false);
		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		for (int i = 0; i < maxPlayers_; i++) {
			for (int j = 0; j < numOfPieces_; j++)
				player_[i][j].setVisible(false);
		}

		player1Piece_.setVisible(false);
		player2Piece_.setVisible(false);
		player3Piece_.setVisible(false);
		player4Piece_.setVisible(false);
		player5Piece_.setVisible(false);
		player6Piece_.setVisible(false);
		player7Piece_.setVisible(false);
		player8Piece_.setVisible(false);
		
		selectPieces_.setVisible(false);
		playerOne_2_.setVisible(false);
		playerTwo_2_.setVisible(false);
		playerThree_2_.setVisible(false);
		playerFour_2_.setVisible(false);
		playerFive_2_.setVisible(false);
		playerSix_2_.setVisible(false);
		playerSeven_2_.setVisible(false);
		playerEight_2_.setVisible(false);
		
		icons_[0].clearSelection();
		icons_[1].clearSelection();
		icons_[2].clearSelection();
		icons_[3].clearSelection();
		icons_[4].clearSelection();
		icons_[5].clearSelection();
		icons_[6].clearSelection();
		icons_[7].clearSelection();
		refreshPieceButtons();

		player1Piece_.setIcon(null);
		player2Piece_.setIcon(null);
		player3Piece_.setIcon(null);
		player4Piece_.setIcon(null);
		player5Piece_.setIcon(null);
		player6Piece_.setIcon(null);
		player7Piece_.setIcon(null);
		player8Piece_.setIcon(null);

		pieceError_.setVisible(false);

		playGame_.setVisible(false);
	}

	public void showOne() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		
		playerTwo_.setVisible(false);
		nameTwo_.setVisible(false);
		playerThree_.setVisible(false);
		nameThree_.setVisible(false);
		playerFour_.setVisible(false);
		nameFour_.setVisible(false);
		playerFive_.setVisible(false);
		nameFive_.setVisible(false);
		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		nameTwo_.setText(null);
		nameThree_.setText(null);
		nameFour_.setText(null);
		nameFive_.setText(null);
		nameSix_.setText(null);
		nameSeven_.setText(null);
		nameEight_.setText(null);
		
	}
	public void showTwo() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		playerTwo_.setVisible(true);
		nameTwo_.setVisible(true);
		
		playerThree_.setVisible(false);
		nameThree_.setVisible(false);
		playerFour_.setVisible(false);
		nameFour_.setVisible(false);
		playerFive_.setVisible(false);
		nameFive_.setVisible(false);
		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		nameThree_.setText(null);
		nameFour_.setText(null);
		nameFive_.setText(null);
		nameSix_.setText(null);
		nameSeven_.setText(null);
		nameEight_.setText(null);

	}

	public void showThree() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		playerTwo_.setVisible(true);
		nameTwo_.setVisible(true);
		playerThree_.setVisible(true);
		nameThree_.setVisible(true);
		
		playerFour_.setVisible(false);
		nameFour_.setVisible(false);
		playerFive_.setVisible(false);
		nameFive_.setVisible(false);
		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		nameFour_.setText(null);
		nameFive_.setText(null);
		nameSix_.setText(null);
		nameSeven_.setText(null);
		nameEight_.setText(null);

	}

	public void showFour() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		playerTwo_.setVisible(true);
		nameTwo_.setVisible(true);
		playerThree_.setVisible(true);
		nameThree_.setVisible(true);
		playerFour_.setVisible(true);
		nameFour_.setVisible(true);
	
		playerFive_.setVisible(false);
		nameFive_.setVisible(false);
		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		nameFive_.setText(null);
		nameSix_.setText(null);
		nameSeven_.setText(null);
		nameEight_.setText(null);

	}

	public void showFive() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		playerTwo_.setVisible(true);
		nameTwo_.setVisible(true);
		playerThree_.setVisible(true);
		nameThree_.setVisible(true);
		playerFour_.setVisible(true);
		nameFour_.setVisible(true);
		playerFive_.setVisible(true);
		nameFive_.setVisible(true);

		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		nameSix_.setText(null);
		nameSeven_.setText(null);
		nameEight_.setText(null);
	}

	public void showSix() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		playerTwo_.setVisible(true);
		nameTwo_.setVisible(true);
		playerThree_.setVisible(true);
		nameThree_.setVisible(true);
		playerFour_.setVisible(true);
		nameFour_.setVisible(true);
		playerFive_.setVisible(true);
		nameFive_.setVisible(true);
		playerSix_.setVisible(true);
		nameSix_.setVisible(true);
		
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		nameSeven_.setText(null);
		nameEight_.setText(null);
		
	}

	public void showSeven() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		playerTwo_.setVisible(true);
		nameTwo_.setVisible(true);
		playerThree_.setVisible(true);
		nameThree_.setVisible(true);
		playerFour_.setVisible(true);
		nameFour_.setVisible(true);
		playerFive_.setVisible(true);
		nameFive_.setVisible(true);
		playerSix_.setVisible(true);
		nameSix_.setVisible(true);		
		playerSeven_.setVisible(true);
		nameSeven_.setVisible(true);
		
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);

		nameEight_.setText(null);
		
	}

	public void showEight() {
		playerOne_.setVisible(true);
		nameOne_.setVisible(true);
		playerTwo_.setVisible(true);
		nameTwo_.setVisible(true);
		playerThree_.setVisible(true);
		nameThree_.setVisible(true);
		playerFour_.setVisible(true);
		nameFour_.setVisible(true);
		playerFive_.setVisible(true);
		nameFive_.setVisible(true);
		playerSix_.setVisible(true);
		nameSix_.setVisible(true);		
		playerSeven_.setVisible(true);
		nameSeven_.setVisible(true);
		playerEight_.setVisible(true);
		nameEight_.setVisible(true);
		
	}

	public void backToMain() {
		
		playerOne_.setVisible(false);
		nameOne_.setVisible(false);
		playerTwo_.setVisible(false);
		nameTwo_.setVisible(false);
		playerThree_.setVisible(false);
		nameThree_.setVisible(false);
		playerFour_.setVisible(false);
		nameFour_.setVisible(false);
		playerFive_.setVisible(false);
		nameFive_.setVisible(false);
		playerSix_.setVisible(false);
		nameSix_.setVisible(false);
		playerSeven_.setVisible(false);
		nameSeven_.setVisible(false);
		playerEight_.setVisible(false);
		nameEight_.setVisible(false);
		
		nameOne_.setText(null);
		nameTwo_.setText(null);
		nameThree_.setText(null);
		nameFour_.setText(null);
		nameFive_.setText(null);
		nameSix_.setText(null);
		nameSeven_.setText(null);
		nameEight_.setText(null);
		
		numberOfPlayers_ = 0;

		longNameError_.setVisible(false);
		repeatError_.setVisible(false);
		noNameError_.setVisible(false);
		mainMenu_.showMenu();
		this.setVisible(false);
	}

	public void backToFirstPage() {
		hideSecondPagePanels();
		showFirstPagePanels();

		optionsPageNum_ = 1;
	}

}
